package com.ruoyi.stuclient.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.stuclient.domain.EwcChapter;
import com.ruoyi.stuclient.domain.dto.ChapterRaiseHandDto;
import com.ruoyi.stuclient.domain.vo.TodayCourseChapterVo;
import com.ruoyi.stuclient.mapper.EwcChapterMapper;
import com.ruoyi.stuclient.service.IEwcChapterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 章节信息Service业务层处理
 * 
 * @author lcj
 * @date 2025-02-27
 */
@Service
public class EwcChapterServiceImpl extends ServiceImpl<EwcChapterMapper, EwcChapter> implements IEwcChapterService {

    @Autowired
    private EwcChapterMapper chapterMapper;

    @Override
    public List<TodayCourseChapterVo> getCourseInProgress(String studentId, String nowDate) {
        return chapterMapper.getCourseInProgress(studentId,nowDate);
    }

    @Override
    public EwcChapter getChapterStatus(ChapterRaiseHandDto chapterRaiseHandDto) {
        QueryWrapper<EwcChapter> updateWrapper = new QueryWrapper<>();
        updateWrapper.eq("id", chapterRaiseHandDto.getId());
        updateWrapper.eq("course_id", chapterRaiseHandDto.getCourseId());
        updateWrapper.eq("class_id", chapterRaiseHandDto.getClassId());
        return this.getOne(updateWrapper);
    }
}
